package com.example.demo.TextTest;

import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;

/**
 * @author LHH
 * @date 2024/12/4
 */
public class forTest {
    public static void main(String[] args) {
//        factorialRecur(5);
        randomNumbers(5);
    }

    // 阶乘阶 O(n!)
    static int factorialRecur(int n) {
        if (n == 0) {
            return 1;
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            count += factorialRecur(n - 1);
            System.out.println("n:" + n + "; i:" + i + "; count:" + count);
        }
        return count;
    }

    //
    static int[] randomNumbers(int n) {
        Integer[] nums = new Integer[n];
        for (int i = 0; i < n; i++) {
            nums[i] = i + 1;
        }
        Collections.shuffle(Arrays.asList(nums));
        int[] res = new int[n];
        for (int i = 0; i < res.length; i++) {
            res[i] = nums[i];
            System.out.println("i:" + i + "; nums[i]:" + nums[i]);
        }
        return res;
    }
}
